<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>复用</title>
</head>
<body>


<div id="box1">box1</div>
<label>部门:</label><select id="sltDept"></select>
<label>职务:</label><select id="sltTitle"></select>
<label>上级:</label><select id="sltSuper"></select>

</body>
<script src="../../lib/jquery.js"></script>
<script type="module">


    import {depts,titles} from '../../mock/dict.js'

    /**
     *  不要重复制造轮子
     * */
    function initSelect(items,selector) {
        $.each(items, function (index, item) {
            let opt = $('<option></option>').val(item.id).text(item.name)
            $(selector).append(opt);
        })
    }

    initSelect(depts,'#sltDept');
    initSelect(titles,'#sltTitle')


</script>


</html>